#pragma once

using namespace std;
#include <filesystem>  // C++17
#include <cmath>
#include <limits>

// flow information
// #define FLOW_CSV_PATH "./flow.csv"
// #define PWD "/home/ailanxier/work/RTA/"
#define PWD "/Users/ailanxier/study/rust_shyper/rta/flow/"

// #define FLOW_CSV_PATH PWD "lpa.csv"
#define FLOW_CSV_PATH PWD "test.csv"
#define LPAS_RESULT_CSV_PATH PWD "lpas.csv"
#define LPA_RESULT_CSV_PATH PWD "lpa.csv"
#define TPA_RESULT_CSV_PATH PWD "tpa.csv"
#define RESULT_CSV_PATH "./res.csv"
#define LOG_PATH "./log.txt"
#define MAX_LINE_SIZE 1000
static const double CBIT_WRITE    = 0.035;     // 50 ns/bit
static const double CBIT_READ     = 0.016;     // 16 ns/bit
static const double DIFF          = 1e-6;
static const double UNSCHEDULABLE = numeric_limits<double>::max() / 2 - 1;
#define QUEUE_SIZE 8
#define NEW_PRIORITY_NUM 8
#define VM_NUM 3

// error code
#define ERROR_SHM_EMPTY -1
#define ERROR_SHM_NOT_ACKED 10
#define ERROR_SET_SHM 11
#define ERROR_GET_SHM -2
#define ERROR_SEND_FAIL 13
#define ERROR_RECV_FROM_THREAD 14
#define SUCCESS 1

// result
#define PRINT_EVERY_COUNT 1000
#define RESULT_MAX_SIZE 1024
#define END_OF_RESULT "*"

// type redefinition
typedef unsigned long long u64;
typedef unsigned long long uint64;

static inline int min(u64 a, u64 b)
{
    return (a < b) ? a : b;
}

inline bool IsSame(double a, double b) {
    return fabs(a - b) < DIFF;
}